package com.moli.iov.down.command.design.strategy.commandreqdto.impl;

import com.moli.iov.down.enums.command.CommandEnum;
import com.moli.iov.down.enums.command.TerminalSettingEnum;
import com.moli.iov.down.model.dto.remoting.CommandDto;
import com.moli.iov.down.model.dto.remoting.CommandReqDto;
import com.moli.iov.down.model.dto.remoting.extend.CommandExtendDto;
import com.moli.iov.down.command.design.strategy.commandreqdto.CommandReqDtoStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 实时数据上报频率
 * </p>
 *
 * @author: zql
 * @Date: 2018/12/28 12:01
 */
public class ChangeRealTimeStrategy implements CommandReqDtoStrategy {

    @Override
    public CommandDto make(CommandReqDto commandReqDto) {
        CommandDto commandDto = new CommandDto();
        commandDto.setVin(commandReqDto.getVin());
        commandDto.setIsRetry(commandReqDto.getIsRetry());

        commandDto.setCommand(CommandEnum.TERMINAL_PARAMETER_SETTING.getFlag());

        List<String> parameterIds = Arrays.asList(TerminalSettingEnum.DATA_FREQUENCY.getFlag());
        commandDto.setParameterIds(parameterIds);

        List<CommandExtendDto> commandExtendDtos = new ArrayList<>();
        CommandExtendDto commandExtendDtoRealTime = new CommandExtendDto();
        commandExtendDtoRealTime.setParameterId(TerminalSettingEnum.DATA_FREQUENCY.getFlag());
        commandExtendDtoRealTime.setParameterContent(String.valueOf(commandReqDto.getFrequency()));
        commandExtendDtos.add(commandExtendDtoRealTime);

        commandDto.setCommandExtendDtos(commandExtendDtos);
        return commandDto;
    }
}
